/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Game={
    create:function () {
        var game={};
        var arr_circle=[];
        game.ui=new PIXI.DisplayObjectContainer();
        var con_circle=new PIXI.Sprite();


        var pageSee=PageSee.create();
        var choose=Choose.create();
        var pageGame=PageGame.create();

        pageSee.In();
        game.ui.addChild(pageSee.ui);
        // choose.In();
        // game.ui.addChild(choose.ui);


        volumeChange(1);
        var bt_music=Easy.CreateSprite('assets/images/bt_music.png',650,54,0.5,0.5,1);
        bt_music.alpha=1;
        bt_music.interactive=true;
        bt_music.on('pointerdown',musicHandler);
        var tw=TweenMax.to(bt_music.scale,1,{repeat:-1,yoyo:true,x:0.9,y:0.9,ease:Cubic.easeInOut});
        game.ui.addChild(bt_music);

        document.addEventListener('Game_PageIn',pageInHandler);

        function musicHandler(e)
        {
            if(bt_music.alpha>0.95)
            {
                tw.pause();
                bt_music.alpha=0.9;
                volumeChange(0);
            }
            else
            {
                bt_music.alpha=1;
                tw.resume();
                volumeChange(1);
            }
        }

        function pageInHandler(e)
        {
            if(e.detail=='choose')
            {
                if(pageGame.ui.parent)
                {
                    pageGame.ui.parent.removeChild(pageGame.ui)
                }
                choose.In();
                game.ui.addChild(choose.ui);
            }
            else if(e.detail[0]=='pageGame')
            {
                if(choose.ui.parent)
                {
                    choose.ui.parent.removeChild(choose.ui)
                }
                game.ui.addChild(pageGame.ui);
                pageGame.In(Math.floor(e.detail[1]));
            }
            // if(e.detail=='0')
            // {
            //     game.ui.addChild(page0.ui);
            //     page0.In();
            // }
            // else if(e.detail=='1')
            // {
            //      game.ui.addChild(page1.ui);
            //      page1.In();
            // }
            // else if(e.detail=='mc')
            // {
            //     game.ui.addChild(pageMC.ui);
            //     pageMC.In();
            // }
        }

        return game;
    }

}